// 导入 configureStore 方法, 用于创建、配置 store 对象
import { configureStore } from "@reduxjs/toolkit";
import {
    persistReducer,
    FLUSH,
    REHYDRATE,
    PAUSE,
    PERSIST,
    PURGE,
    REGISTER,
} from 'redux-persist'
import storage from 'redux-persist/lib/storage'

import UserInfo from "./user";
import FilterInfo from "./filter";

const persistConfig={
    key:'root',
    storage,
}
const UserInfoReducer = persistReducer(persistConfig, UserInfo)

// 创建、配置、导出 store 对象
export default configureStore({
    // 是否开启浏览器的 redux 开发者调试工具
    devTools: true,
    // reducer 选项用于替换原有的 combineReducers 方法, 用于合并应用中的多个 reducer 函数, 组成最终的 Store 对象
    reducer: {
        userinfo:UserInfoReducer,
        filterinfo:FilterInfo
    },
    middleware: (getDefaultMiddleware) =>
        getDefaultMiddleware({
            serializableCheck: {
                ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER],
            },
        }),
});
